package com.demo.admin;


import com.demo.common.model.Category;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class AdminValidator extends Validator{
	protected void validate(Controller controller) {
		validateRequiredString("category.name", "nameMsg", "请输入分类名称!");
	}
	protected void handleError(Controller controller) {
		controller.keepModel(Category.class);
		
		String actionKey = getActionKey();
		if (actionKey.equals("/admin/savecategory")){
			controller.setAttr("addclass_display","addclass_display"); 
			controller.render("addclass.html");
		}
			
		else if (actionKey.equals("/admin/updatecategory")){
			controller.setAttr("classlist_display","classlist_display"); 
			controller.render("editcategory.html");
		}
			
	}
}
